<?php

namespace app\admin\model;

use think\Model;


class Card extends Model
{

    

    

    // 表名
    protected $name = 'card';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'card_type_text',
        'card_display_text'
    ];
    

    
    public function getCardTypeList()
    {
        return ['1' => __('Card_type 1'), '2' => __('Card_type 2')];
    }

    public function getCardDisplayList()
    {
        return ['0' => __('Card_display 0'), '1' => __('Card_display 1')];
    }


    public function getCardTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['card_type']) ? $data['card_type'] : '');
        $list = $this->getCardTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getCardDisplayTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['card_display']) ? $data['card_display'] : '');
        $list = $this->getCardDisplayList();
        return isset($list[$value]) ? $list[$value] : '';
    }




}
